package com.solution.admin.product.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.solution.admin.product.dao.ProductInvisiableDao;
import com.solution.admin.product.entity.ProductInvisiableEntity;
import com.solution.admin.product.service.ProductInvisiableService;
import com.solution.common.dao.BaseDao;
import com.solution.common.page.PageBean;
import com.solution.common.page.PageParam;
import com.solution.common.service.impl.BaseServiceImpl;

/**
 * 商品可见性service实现层
 * @author solin
 * @date 2017-09-20 15:31:21
 */
@Service
public class ProductInvisiableServiceImpl extends BaseServiceImpl<ProductInvisiableEntity> implements ProductInvisiableService {

	/**
	 * 商品可见性接口
	 */
	@Autowired
	private ProductInvisiableDao ebProductInvisiableDao;

	protected BaseDao<ProductInvisiableEntity> getDao() {
		return this.ebProductInvisiableDao;
	}

	/**
	 * 保存商品可见性
	 * @param ebProductInvisiableEntity 商品可见性实体
	 * @return Long 添加成功商品可见性的ID
	 * @author solin
	 * @date 2017-09-20 15:31:21
	 */
	public long saveEbProductInvisiable(ProductInvisiableEntity ebProductInvisiableEntity) {
		return ebProductInvisiableDao.saveEbProductInvisiable(ebProductInvisiableEntity);
	}
	
	/**
	 * 批量保存商品可见性
	 * @param ebProductInvisiableEntity 商品可见性实体
	 * @return Long 返回插入商品可见性记录ID
	 * @author solin
	 * @date 2017-09-20 15:31:21
	 */
	@Transactional(rollbackFor=Exception.class)
	public long batchSaveProductInvisiable(Long productId, List<ProductInvisiableEntity> productInvisiableList){
		ebProductInvisiableDao.deleteEbProductInvisiableByProductId(productId);
		if (productInvisiableList.size() > 0) {
			ebProductInvisiableDao.insert(productInvisiableList);
		}
		return 1L;
	}

	/**
	 * 分页查询商品可见性
	 * @param pageParam 分页参数
	 * @param paramMap 查询参数
	 * @return PageBean 分页参数和分页数据
	 * @author solin
	 * @date 2017-09-20 15:31:21
	 */
	@Override
	public PageBean listEbProductInvisiablePage(PageParam pageParam, Map<String, Object> paramMap) {
		return ebProductInvisiableDao.listEbProductInvisiablePage(pageParam, paramMap);
	}
	
	/**
	 * 根据ID查询用户信息
	 * @param id 用户id
	 * @return ebProductInvisiableEntity 用户对象
	 * @author solin
	 * @date 2017-09-20 15:31:21
	 */
	public ProductInvisiableEntity getEbProductInvisiableById(Long id) {
		return ebProductInvisiableDao.getById(id.longValue());
	}

	/**
	 * 更新用户
	 * @param ebProductInvisiableEntity 用户实体
	 * @return Long 更新是否成功，>1代表更新成功
	 * @author solin
	 * @date 2017-09-20 15:31:21
	 */
	@Override
	public int updateEbProductInvisiable(ProductInvisiableEntity ebProductInvisiableEntity) {
		return ebProductInvisiableDao.updateEbProductInvisiable(ebProductInvisiableEntity);
	}
	
	
	/**
	 * 根据条件查询商品可见性
	 * @param param
	 * @return 数据列表
	 * @author solin
	 * @date 2017-09-20 15:31:21
	 */
	@Override
	public List<ProductInvisiableEntity> listEbProductInvisiable( Map<String, Object> param){
		return  ebProductInvisiableDao.listEbProductInvisiable(param);
	}
	
	/**
	 * 删除商品可见性
	 * @param 
	 * @return int 返回删除记录条数
	 * @author solin
	 * @date 2017-09-20 15:31:21
	 */
	public int deleteEbProductInvisiableById(long id){
		return  ebProductInvisiableDao.deleteById(id);
	}
	
	/**
	 * 根据商品ID删除商品可见性
	 * @param 
	 * @return int 返回删除记录条数
	 * @author solin
	 * @date 2017-09-20 15:31:21
	 */
	public int deleteEbProductInvisiableByProductId(long productId) {
		return  ebProductInvisiableDao.deleteEbProductInvisiableByProductId(productId);
	}
}
